<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login | ScMarket Login</title>
<link href="css/960.css" rel="stylesheet" type="text/css" media="all" />
<link href="css/reset.css" rel="stylesheet" type="text/css" media="all" />
<link href="css/text.css" rel="stylesheet" type="text/css" media="all" />
<link href="css/login.css" rel="stylesheet" type="text/css" media="all" />

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	
	$("#ingresar").click(function() {
	$("#mensaje").slideUp("slow");
		var action = $("#form1").attr('action');
		var form_data = {
			usuario: $("#usuario").val(),
			clave: $("#clave").val(),
			
			is_ajax: 1
		};
		
			$("#cargando").css("display", "inline");		

		$.ajax({
			type: "POST",
			url: action,
			data: form_data,
			success: function(response)
			{
				if(response == 'success'){
					
					
					$("#cargando").css("display", "none");
					$("#login").slideUp("slow",function(){
						$("#caja").slideDown("slow",function(){
							$("#ingresar_caja").click(function(){
								if($("#cajero").val()!="-1" & $("#caja").val()!="-1"){
									
									
											var act= $("#form2").attr('action');
		var form = {
			cajero: $("#cajero").val(),
			cajac: $("#cajac").val(),
			cajero_nombre: $("#cajero option:selected").text(),
			cajac_nombre: $("#cajac option:selected").text(),
			
			is_ajax: 1
		};									
			$.ajax({
			type: "POST",
			url: act,
			data: form,
			success: function(res)
			{
				if(res== 'paso_caja'){
					
				}
			}
			});
									
									
									
									$("#mensaje").slideDown("fast");
									$("#mensaje").html("<p  id='success'><span>Autorizado!</span></p>");
									$("#caja").slideUp("slow",function(){
										$("#logo_sc").fadeIn(1100,function(){
										$(location).attr('href',"menu.php");
										});	
									});

								}
							});
							
						});

					
					});
						
					}
				else{
					//alert(response);//
					$("#cargando").css("display", "none");
				$("#mensaje").html("<p class='info' id='error'><span>Nombre de usuario o clave erroneos</span></p>");
				$("#mensaje").slideDown("slow");
						
					
				}
			}
		});
		
		return false;
	});
	
});
</script>
</head>

<body>
<div class="container_16">
  <div class="grid_6 prefix_5 suffix_5">
   	  <h1>Bienvenido a ScMarket</h1>
   	  
    	<div id="login">
    	  <form id="form1" name="form1" method="post" action="login.php">
    	    <p>
    	      <label><strong>Usuario</strong>
<input type="text" name="usuario" class="inputText" id="usuario">
    	      </label>
  	      </p>
    	    <p>
    	      <label><strong>Clave</strong>
  <input type="password" name="clave" class="inputText" id="clave" />
  	        </label>
    	    </p>
    		<a class="black_button" id="ingresar"><span>&nbsp&nbsp&nbspIngresar&nbsp&nbsp&nbsp</span></a><img src="images/ajax-loader.gif" id="cargando" style="display:none;">
    		<!--<button  class="black_button" name="do" value="ingresar" >Ingresar</button> --> 
             <label>
                   
    	  </form>
		  <br clear="all" />
    	</div>
    	    	<div id="caja">
    	  <form id="form2" name="form2" method="post" action="login.php">
    	    <p>
    	      <label><strong>Cajero</strong>
<select name='cajero' id="cajero" class="check">
<optgroup label='Cajeros Disponibles'>";
	<option value="-1" selected="selected"></option>
	<?php
	include "includes/conexion.php";
$qry=mysql_query("select * from caj_cajeros");
while($row=mysql_fetch_row($qry)){
echo "<option value='$row[0]'>$row[1]</option>";
}
?>
</select>
    	      </label>
  	      </p>
    	    <p>
    	      <label><strong>Caja</strong>
<select name='cajac' id="cajac" class="check">
<optgroup label='Cajas Disponibles'>";
	<option value="-1" selected="selected"></option>
	<?php
$qry=mysql_query("select * from cja_cajas");
while($row=mysql_fetch_row($qry)){
echo "<option value='$row[0]'>$row[1]</option>";
}
?>
</select>
  	        </label>
    	    </p>
    		<a class="black_button" id="ingresar_caja"><span>&nbsp&nbsp&nbspIngresar&nbsp&nbsp&nbsp</span></a><img src="images/ajax-loader.gif" id="cargando" style="display:none;">
    		<!--<button  class="black_button" name="do" value="ingresar" >Ingresar</button> --> 
             <label>
                   
    	  </form>
		  <br clear="all" />
    	</div>
        
        <div id="mensaje">
		</div>
		<div id="logo_sc">
			<div id="texto">
				<h2>Redirigiendo...</h2>
			</div>
		</div>
  </div>
</div>
<br clear="all" />
</body>
</html>
